/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.comac.ins.common.core.domain.R;
import com.comac.ins.common.core.validate.AddGroup;
import com.comac.ins.common.core.validate.EditGroup;
import com.comac.ins.common.excel.utils.ExcelUtil;
import com.comac.ins.common.idempotent.annotation.RepeatSubmit;
import com.comac.ins.common.log.annotation.Log;
import com.comac.ins.common.log.enums.BusinessType;
import com.comac.ins.common.mybatis.core.page.TableDataInfo;
import com.comac.ins.common.web.core.BaseController;
import com.comac.ins.isfd.domain.bo.IsfdMetalMaterialStaticStrengthAnalysisBo;
import com.comac.ins.isfd.domain.bo.query.IsfdMetalMaterialStaticStrengthAnalysisQueryBo;
import com.comac.ins.isfd.domain.vo.IsfdMetalMaterialStaticStrengthAnalysisVo;
import com.comac.ins.isfd.service.IIsfdMetalMaterialStaticStrengthAnalysisService;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 金属材料-静强度分析
 *
 * @author hxloongs
 * @date 2025-08-20
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/isfd/metalMaterialStaticStrengthAnalysis")
public class IsfdMetalMaterialStaticStrengthAnalysisController extends BaseController {

    @Autowired
    private IIsfdMetalMaterialStaticStrengthAnalysisService isfdMetalMaterialStaticStrengthAnalysisService;

    /**
     * 查询金属材料-静强度分析列表
     */
    @SaCheckPermission("isfd:metalMaterialStaticStrengthAnalysis:list")
    @PostMapping("/list")
    public TableDataInfo<IsfdMetalMaterialStaticStrengthAnalysisVo> list(@RequestBody IsfdMetalMaterialStaticStrengthAnalysisQueryBo queryBo) {
        return isfdMetalMaterialStaticStrengthAnalysisService.queryPageList(queryBo);
    }

    /**
     * 导出金属材料-静强度分析列表
     */
    @SaCheckPermission("isfd:metalMaterialStaticStrengthAnalysis:export")
    @Log(title = "金属材料-静强度分析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(IsfdMetalMaterialStaticStrengthAnalysisBo bo, HttpServletResponse response) {
        List<IsfdMetalMaterialStaticStrengthAnalysisVo> list = isfdMetalMaterialStaticStrengthAnalysisService.queryList(bo);
        ExcelUtil.exportExcel(list, "金属材料-静强度分析", IsfdMetalMaterialStaticStrengthAnalysisVo.class, response);
    }

    /**
     * 获取金属材料-静强度分析详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("isfd:metalMaterialStaticStrengthAnalysis:query")
    @GetMapping("/{id}")
    public R<IsfdMetalMaterialStaticStrengthAnalysisVo> getInfo(@NotNull(message = "主键不能为空")
                                                                @PathVariable Long id) {
        return R.ok(isfdMetalMaterialStaticStrengthAnalysisService.queryById(id));
    }

    /**
     * 新增金属材料-静强度分析
     */
    @SaCheckPermission("isfd:metalMaterialStaticStrengthAnalysis:add")
    @Log(title = "金属材料-静强度分析", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody IsfdMetalMaterialStaticStrengthAnalysisBo bo) {
        return toAjax(isfdMetalMaterialStaticStrengthAnalysisService.insertByBo(bo));
    }

    /**
     * 修改金属材料-静强度分析
     */
    @SaCheckPermission("isfd:metalMaterialStaticStrengthAnalysis:edit")
    @Log(title = "金属材料-静强度分析", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody IsfdMetalMaterialStaticStrengthAnalysisBo bo) {
        return toAjax(isfdMetalMaterialStaticStrengthAnalysisService.updateByBo(bo));
    }

    /**
     * 删除金属材料-静强度分析
     *
     * @param ids 主键串
     */
    @SaCheckPermission("isfd:metalMaterialStaticStrengthAnalysis:remove")
    @Log(title = "金属材料-静强度分析", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(isfdMetalMaterialStaticStrengthAnalysisService.deleteWithValidByIds(List.of(ids)));
    }
}
